import React, { Component } from 'react';
import axios from 'axios';
import Film from './components/film';
import Film2 from './components/film2';

export default class App extends Component {
    state = {
        list:[]
    }
    constructor(){
    super();
      axios({
          url:'https://m.maizuo.com/gateway?cityId=440300&pageNum=1&pageSize=10&type=1&k=3889594',
          headers:{
            'X-Client-Info': '{"a":"3000","ch":"1002","v":"5.2.0","e":"165294070798642513887233"}',
            'X-Host': 'mall.film-ticket.film.list'
          }
      }).then(res =>{
          this.setState({
              list:res.data.data.films
          })
          console.log(res.data.data.films)
      })
  }
  render() {
    return (
      <div>
          {
            this.state.list.map((item)=>
              <Film key={item.filmId} name={item.name} detail={item.synopsis} event={(detail)=>{
                this.setState({
                  detail:detail
                })
              }}></Film>
            )
          }
          <Film2 detail={this.state.detail}></Film2>
      </div>
    )
  }
}
